package com.pointstar.dp.common.entity;

/**
 * @author 朱科睿
 */
public class ApiResult<T> {

    private Integer code;
    private String msg;
    private T data;

    public ApiResult success(){
        this.code = ResultCode.SUCCESS.getCode();
        this.msg = ResultCode.SUCCESS.getDesc();
        return this;
    }

    public ApiResult success(T data){
        this.code = ResultCode.SUCCESS.getCode();
        this.msg = ResultCode.SUCCESS.getDesc();
        this.data = data;
        return this;
    }

    public ApiResult failure(){
        this.code = ResultCode.ERROR.getCode();
        this.msg = ResultCode.ERROR.getDesc();
        return this;
    }

    public ApiResult failure(T data){
        this.code = ResultCode.ERROR.getCode();
        this.msg = ResultCode.ERROR.getDesc();
        this.data = data;
        return this;
    }
}
